import { createSSRApp } from "vue";
import App from "./App.vue";
import { authActions, authGetters, authState } from "./store/modules/auth";
import { onAppLaunch } from "./utils/router-guard";

export function createApp() {
  const app = createSSRApp(App);

  // 全局认证状态管理
  app.config.globalProperties.$auth = {
    state: authState,
    getters: authGetters,
    actions: authActions
  };

  // 初始化认证状态
  authActions.initAuthState();

  // 应用启动时的权限检查
  onAppLaunch();

  return {
    app,
    // 导出认证状态，方便其他地方使用
    authState,
    authGetters,
    authActions
  };
}
